package com.zsyh.jiujiu.home;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.blankj.utilcode.util.ActivityUtils;
import com.bumptech.glide.Glide;
import com.example.zyh.toolslib.base.BaseActivity;
import com.example.zyh.toolslib.utils.SPUtils;
import com.example.zyh.toolslib.widget.TitleBar;
import com.google.gson.Gson;
import com.lwb.retrofit.RetrofitTask;
import com.zsyh.jiujiu.Api;
import com.zsyh.jiujiu.R;
import com.zsyh.jiujiu.bean.MyInfoBeeean;
import com.zsyh.jiujiu.net.MyFragementObserver;
import com.zsyh.jiujiu.net.MyObserver;
import com.zsyh.jiujiu.utils.GlideCircleTransform;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * @ProjectName: livvehelp
 * @Package: com.zsyh.lsb.ui
 * @ClassName:
 * @Description: java类作用描述
 * @Author: zsyh
 * @CreateDate: 2020/9/7 11:59
 * @UpdateUser: liangwanbo
 * @UpdateDate: 2020/9/7 11:59
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class CxRenzhengActivity extends BaseActivity {

    @BindView(R.id.title_bar)
    TitleBar titleBar;
    @BindView(R.id.kaitong)
    TextView kaitong;
    private String isHonestyCheck;

    @Override
    protected int initLayout() {
        return R.layout.activity_chengxin;
    }

    @Override
    protected void initView() {
        titleBar.setLeftLayoutClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    protected void initData() {
        getUser((String) SPUtils.get(thisActivity, "userid", ""));
    }

    @Override
    protected void initEvent() {

    }



    @OnClick(R.id.kaitong)
    public void onViewClicked() {
        if(isHonestyCheck.equals("审核中")){
            return;
        }

        if(isHonestyCheck.equals("审核通过")){
            return;
        }
        ActivityUtils.startActivity(GoRenzhengActivity.class);
        thisActivity.finish();
    }


    public void getUser(String userid) {
        RetrofitTask.getInstance()
                .createApi(Api.class)
                .getUserById(userid)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new MyObserver(this, false) {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(String JsonStr) {
                        Log.e("Myinfo", JsonStr + "");
                        Gson gson = new Gson();
                        MyInfoBeeean myInfoBeeean = gson.fromJson(JsonStr, MyInfoBeeean.class);
                        isHonestyCheck=myInfoBeeean.getData().getIsHonestyCheck();
                        kaitong.setText(isHonestyCheck);


                    }
                });
    }
}
